<template>
  <div class="dashboard-editor-container">
    <div class="dashboard-header">
      <h2 class="dashboard-title">四级联考系统</h2>

      <el-button type="danger" icon="el-icon-refresh" class="system-init-btn" @click="handleInit">
        系统初始化
      </el-button>
    </div>

<!--    <panel-group :panel-data="panelData" @handle-set-line-chart-data="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <rose-pie-chart :chart-data="qualifiedScoreData" />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <donut-chart :chart-data="qualificationData" />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <radar-chart :chart-data="dbIdentityData" />
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <multi-bar-chart :chart-data="physicalData" />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <funnel-chart :chart-data="dbQualificationData" />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <complete-funnel-chart :chart-data="finalReviewData" />
        </div>
      </el-col>
    </el-row>-->
  </div>
</template>

<script>
/*import PanelGroup from './dashboard/components/PanelGroup'
import LineChart from './dashboard/components/LineChart'
import RosePieChart from './dashboard/components/RosePieChart'
import DonutChart from './dashboard/components/DonutChart'
import MultiBarChart from './dashboard/components/MultiBarChart'
import FunnelChart from './dashboard/components/FunnelChart'
import RadarChart from './dashboard/components/RadarChart'
import CompleteFunnelChart from './dashboard/components/CompleteFunnelChart'
import { getScoreStatistics } from "@/api/system/db_score_management"
import { getQualifiedScoreStatistics } from "@/api/system/db_qualified_score"
import { getQualificationStatistics } from "@/api/system/db_qualification"
import { getIdentityStatistics } from "@/api/system/db_identity"
import { getPhysicalStatistics } from "@/api/system/db_physical"
import { getDbQualificationStatistics } from "@/api/system/db_qualification"
import { getDbIdentityStatistics } from "@/api/system/db_identity"
import { getDbPhysicalStatistics } from "@/api/system/db_physical"
import { getFinalReviewStatistics } from "@/api/system/result"
import { cleanAllData } from "@/api/system/sys_init"*/

import {cleanAllData} from "../api/system/init";

export default {
  name: 'Index',
  /*components: {
    PanelGroup,
    LineChart,
    RosePieChart,
    DonutChart,
    MultiBarChart,
    FunnelChart,
    RadarChart,
    CompleteFunnelChart
  },*/
  /*data() {
    return {
      // 面板数据
      panelData: {
        scores: { total: 0, passed: 0, failed: 0 },
        qualification: { total: 0, passed: 0, failed: 0 },
        identity: { total: 0, passed: 0, failed: 0 },
        physical: { total: 0, passed: 0, failed: 0 }
      },
      // 线图数据
      lineChartData: {
        title: '招聘流程统计',
        subtitle: '各环节数据对比',
        timeline: ['成绩录入', '成绩合格', '资格审查', '身份验证', '体能测试', '递补资格', '递补身份', '递补体能', '终审通过'],
        passedData: [0, 0, 0, 0, 0, 0, 0, 0, 0],
        failedData: [0, 0, 0, 0, 0, 0, 0, 0, 0],
        positionData: []
      },
      // 各模块统计数据
      qualifiedScoreData: { positions: [] },
      qualificationData: { passed: 0, failed: 0 },
      identityData: { passed: 0, failed: 0 },
      physicalData: { positions: [] },
      dbQualificationData: { total: 0, passed: 0, failed: 0 },
      dbIdentityData: { positions: [] },
      dbPhysicalData: { timeline: [], passedData: [], failedData: [], positionData: [] },
      finalReviewData: {
        initialCount: 0,
        scoreCount: 0,
        qualifiedCount: 0,
        qualificationCount: 0,
        identityCount: 0,
        physicalCount: 0,
        dbQualificationCount: 0,
        dbIdentityCount: 0,
        dbPhysicalCount: 0,
        finalCount: 0
      }
    }
  },
  created() {
    this.fetchAllData()
  },*/
  methods: {

    // 系统初始化
    handleInit() {
      this.$confirm('系统初始化将清空所有业务数据，是否继续？', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        cleanAllData().then(response => {
          this.$message.success('系统初始化成功')
        }).catch(error => {
          console.error('系统初始化失败', error)
          this.$message.error('系统初始化失败，请联系管理员')
        })
      }).catch(() => {
        this.$message.info('已取消系统初始化')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .dashboard-header {
    margin-bottom: 24px;
    position: relative;

    .dashboard-title {
      font-size: 24px;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.85);
      margin-bottom: 12px;
    }

    .dashboard-description {
      font-size: 14px;
      color: rgba(0, 0, 0, 0.45);
      margin-bottom: 24px;
    }

    .system-init-btn {
      position: absolute;
      top: 0;
      right: 0;
    }
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px;
    margin-bottom: 32px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    height: 380px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}

@media (max-width: 768px) {
  .dashboard-editor-container {
    padding: 16px;
  }

  .dashboard-header {
    .system-init-btn {
      position: relative;
      margin-top: 12px;
      margin-bottom: 12px;
    }
  }
}
</style>

